<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>EnvAdd</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>EnvAdd</h1>

<p>Sets a <a href="../Variables.htm">variable</a> to the sum of itself plus the given value (can also add or subtract time from a <a href="FileSetTime.htm#YYYYMMDD">date-time</a> value). Synonymous with: <code>var += value</code>.</p>

<pre class="Syntax">EnvAdd, Var, Value [, TimeUnits]
Var += Value [, TimeUnits]
Var++</pre>
<h3>Parameters</h3>
<dl>

  <dt>Var</dt>
  <dd><p>The name of the <a href="../Variables.htm">variable</a> upon which to operate.</p></dd>

  <dt>Value</dt>
  <dd><p>Any integer, floating point number, or <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

  <dt>TimeUnits</dt>
  <dd><p>If present, this parameter directs the command to add <em>Value</em> to <em>Var</em>, treating <em>Var</em> as a  date-time stamp in the <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format and treating <em>Value</em> as the integer or floating point number of units to add (specify a negative number to perform subtraction). <em>TimeUnits</em> can be either Seconds, Minutes, Hours, or Days (or just the first letter of each of these).</p>
      <p>If <em>Var</em> is an empty variable, the current time will be used in its place. If <em>Var</em> contains an invalid timestamp or a year prior to 1601, or if <em>Value</em> is non-numeric, <em>Var</em> will be made blank to indicate the problem.</p>
      <p>The built-in variable <strong>A_Now</strong> contains the current local time in <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format.</p>
      <p>To calculate the amount of time between two timestamps, use <a href="EnvSub.htm">EnvSub</a>.</p></dd>

</dl>

<h3>Remarks</h3>
<p>This command is equivalent to the shorthand style: <code>Var += Value</code>.</p>
<p>Variables can be increased or decreased by 1 by using <code>Var++</code>, <code>Var--</code>, <code>++Var</code>, or <code>--Var</code>.</p>
<p>If either <em>Var</em> or <em>Value</em> is blank or does not start with a number, it is considered to be 0 for the purpose of the calculation (except when used <em>internally</em> in an expression and except when using the <em>TimeUnits</em> parameter).</p>
<p>If either <em>Var</em> or <em>Value</em> contains a decimal point, the end result will be a floating point number in the format set by <a href="SetFormat.htm">SetFormat</a>.</p>
<h3>Related</h3>
<p><a href="EnvSub.htm">EnvSub</a>, <a href="EnvMult.htm">EnvMult</a>, <a href="EnvDiv.htm">EnvDiv</a>, <a href="SetFormat.htm">SetFormat</a>, <a href="../Variables.htm#Expressions">Expressions</a>, <a href="IfIs.htm">If var is [not] type</a>, <a href="SetEnv.htm">SetEnv</a>, <a href="FileGetTime.htm">FileGetTime</a></p>
<h3>Example</h3>
<pre class="NoIndent">EnvAdd, MyCount, 2
MyCount += 2  <em>; Equivalent to above</em>

var1 =  <em>; Make it blank so that the below will use the current time instead.</em>
var1 += 31, days
MsgBox, %var1%  <em>; The answer will be the date 31 days from now.</em></pre>

</body>
</html>
